package com.yuwubao.uav.tool.service.impl;

import com.yuwubao.framework.bean.PageData;
import com.yuwubao.uav.tool.mapper.OrgDynamicMapper;
import com.yuwubao.uav.tool.service.OrgDynamicService;
import com.yuwubao.uav.tool.util.StringUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 */
@Service
public class OrgDynamicServiceImpl implements OrgDynamicService {

    private static final Logger logger = LogManager.getLogger(OrgDynamicServiceImpl.class.getName());

    @Resource
    private OrgDynamicMapper orgDynamicMapper;

    @Override
    public void clickOrgDynamic(PageData pageData) throws Exception {
        try{
            orgDynamicMapper.clickOrgDynamic(pageData);

        }catch (Exception e) {
            logger.debug("",e);
        }
    }
    @Override
    public void deleteOrgDynamic(PageData pageData) throws Exception {
        try{
            String ids = pageData.get("ids") == null ? "" : pageData.getString("ids");
            if (StringUtil.isNotNvlOrBlank(ids)) {
                String[] idArr = ids.split(",");
                if (idArr != null && idArr.length>0) {
                    pageData.put("idArr",idArr);
                    orgDynamicMapper.deleteOrgDynamic(pageData);

                }
            }
        }catch (Exception e) {
            logger.debug("",e);
        }
    }
    @Override
    public void updateOrgDynamic(PageData pageData) throws Exception {
        try{
            orgDynamicMapper.updateOrgDynamic(pageData);
        }catch (Exception e) {
            logger.debug("",e);
        }
    }
    @Override
    public void disableOrEnableOrgDynamic(PageData pageData) throws Exception {
        try{
            String ids = pageData.get("ids") == null ? "" : pageData.getString("ids");
            if (StringUtil.isNotNvlOrBlank(ids)) {
                String[] idArr = ids.split(",");
                if (idArr != null && idArr.length>0) {
                    pageData.put("idArr",idArr);
                    orgDynamicMapper.disableOrEnableOrgDynamic(pageData);

                }
            }
        }catch (Exception e) {
            logger.debug("",e);
        }
    }
    @Override
    public void addOrgDynamic(PageData pageData) throws Exception {
        try{
            orgDynamicMapper.addOrgDynamic(pageData);
        }catch (Exception e) {
            logger.debug("",e);
        }
    }

    @Override
    public List<PageData> listOrgDynamic(PageData pageData) throws Exception {
        try{
            return orgDynamicMapper.listOrgDynamic(pageData);
        }catch (Exception e) {
            logger.debug("",e);
        }
        return null;
    }
    @Override
    public int listOrgDynamicCount(PageData pageData) throws Exception {
        try{
            return orgDynamicMapper.listOrgDynamicCount(pageData);
        }catch (Exception e) {
            logger.debug("",e);
        }
        return 0;
    }


}
